<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jstl/core_rt"  prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML>
<html>
  <head>
    <base href="<%=basePath%>">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<title>热门话题</title>
	<link rel="stylesheet" type="text/css" href="css/normalize.css">
	<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">
	<link rel="stylesheet" type="text/css" href="css/my-style.css">
	<!--[if lt IE 9]> 
		<script src="js/html5shiv.min.js"></script> 
	<![endif]-->
</head>
<body>
	<!-- 导航栏 -->
	<header>
		<nav class="navbar navbar-inverse">
			<div class="container">
				<div class="navbar-header">
					<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar-collapse-1" aria-expanded="false">
		        <span class="sr-only">Toggle navigation</span>
		        <span class="icon-bar"></span>
		        <span class="icon-bar"></span>
		        <span class="icon-bar"></span>
		      </button>
		      <a class="navbar-brand" href="index.html">
		        <img alt="LOGO" src="img/logo.png">
		      </a>
				</div>
				<div class="collapse navbar-collapse" id="navbar-collapse-1">
					<ul class="nav navbar-nav navbar-left">
						<li><a href="index/home">首页</a></li>
	          <li><a href="lawyer/list">法律人</a></li>
	          <li><a href="contract/list">法律产品</a></li>
	        <li><a href="knowledge/index">法律知识</a></li>
	          <li><a href="#">招聘</a></li>
					</ul>

					<ul class="nav navbar-nav navbar-right">
						<li><a class="add-btn" href="index/join">法律人入驻<span class="caret"></span></a></li>
				<c:if test="${sessionScope.user == null}">
					<li><a href="user/login">登录</a></li>
					<li><a href="user/register">注册</a></li>
				</c:if>
				<c:if test="${sessionScope.user != null}">
					 <li>
								<c:if test="${sessionScope.user.type  == 0}">
								<a href="user/person">${sessionScope.user.username}</a>
								</c:if>
								<c:if test="${sessionScope.user.type  == 1}">
								<a href="lawyer/person">${sessionScope.user.username}</a>
								</c:if>
								<c:if test="${sessionScope.user.type  == 2}">
								<a href="lawyer/person">${sessionScope.user.username}</a>
								</c:if>
					    </li>
					<li><a href="user/logout">退出</a></li>
				</c:if>
			</ul>
				</div>
			</div>
		</nav>
	</header>
	

	<section style="margin-top:20px;">
		<div class="container">
			<div class="row">
				<div class="col-md-12">
					<div class="tab-title clearfix">
							<span>首页</span>
							<span class="hidden-xs">我在滴滴法律,我承诺,您的每一个问题,我都会认真解答!</span>
					</div>
					<div class="col-md-12 col-sm-12 col-xs-12 clear-padding" style="background:#fff;padding:10px 0;">
						<div class="tab-topic-con-info">
							<h4><span class="label label-info">${detail.themeid}</span>本周热门话题:<a href="javascript:;">${detail.themename}</a></h4>
							<p>${detail.themecontent}</p>
						</div>
						

					</div>
				</div>
			</div>

			<div class="row">
				<div class="col-md-12">
					<h4 class="law-reg-title" style="margin-left:20px;">评论区</h4>	
					<div class="col-md-12 col-sm-12 col-xs-12 clear-padding" style="background:#fff;padding:10px 20px 0 20px;">
						<c:forEach items="${comments}" var="comments">
						<div class="comment-info">
							
							<a href="#">${comments.username}:</a>
							<p>${comments.commentcon}</p>
							<div class="icon-box text-right">
								<span class="icon icon-clock"><fmt:formatDate value="${comments.commentTime}" pattern="yyyy-MM-dd hh:mm:ss"/></span>
							</div>
						</div>
						</c:forEach>
					</div>					
				</div>
			</div>


			<div class="row">
				<div class="col-md-12">
					<h4 class="law-reg-title" style="margin-left:20px;">参与评论</h4>	
					<div class="col-md-12 col-sm-12 col-xs-12 clear-padding" style="background:#fff;padding:10px 20px;">
						<form action="topic/comment" method="post" id="topic-form">
							<div class="form-group comment-textarea">
								<textarea class="form-control" placeholder="文明上网,参与评论" rows="5" name="commentcon" id="topic-con"></textarea>
								<input type="hidden" name="themesid" value="${detail.themeid}">
								<input type="button" class="btn btn-info" id="topic-btn" value="发表评论">
							</div>
						</form>
					</div>
				</div>
			</div>

		</div>
	</section>

	<script type="text/javascript" src="js/jquery.min.js"></script>
	<script type="text/javascript" src="js/bootstrap.min.js"></script>
	<script type="text/javascript">
		$(function() {
			var topic_rul = /^.{6,200}$/;
			$("#topic-btn").click(function(){
				   var content = $("#topic-con").val();
				   var flag = true;
				   if(content == ""){
						alert("请输入评论!");
						flag = false;
					}else if(!topic_rul.test(content)){
						alert("请输入6~200个字符!");
						flag = false;
					}
				   if(flag){
							$("#topic-form").submit();
				 	}
			});
		});
	</script>
</body>
</html>